package devices

import (
	"context"
	"device_srv/device"
	"device_srv/internal/dao"
	"device_srv/internal/svc"
	"github.com/zeromicro/go-zero/core/logx"
)

type DevicesAddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewDevicesAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DevicesAddLogic {
	return &DevicesAddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// DevicesAdd 设备添加
func (l *DevicesAddLogic) DevicesAdd(in *device.DevicesAddRequest) (*device.DevicesAddResponse, error) {
	//调用业务逻辑
	add, err := dao.DevicesAdd(in)
	if err != nil {
		return nil, err
	}
	return &device.DevicesAddResponse{
		Id: int64(add.Id),
	}, nil
}
